﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

namespace Contrast
{
   public static class WriteFileCls
    {
       public static string PCURL = System.Environment.CurrentDirectory + "\\Pici\\";
       public static string LogURL = System.Environment.CurrentDirectory + "\\LOG\\";


       /// <summary>
       /// 把打印的数据记录下来
       /// </summary>
       /// <param name="Ecode"></param>
       /// <param name="Dcode"></param>
       public static void InserLog(string log)
       {
           string fileName = LogURL + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
           if (!File.Exists(fileName))
           {
               FileStream Fwriter = File.Create(fileName);//创建文件  
               Fwriter.Close();
               Fwriter.Dispose();
              // Thread.Sleep(500);
           }
              StreamWriter writer = File.AppendText(fileName);//文件中添加文件流  
              writer.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss :") +log);  
               writer.Flush();  
               writer.Close();  

       }
    }
}
